filestr='Hello, World!'
file = "test.txt"
with open(file, 'w') as f:
    f.write(filestr)